//Flutter
import 'package:flutter/material.dart';

//Components
import 'package:sakurapuzzle/core/components/dialog/app_dialog.dart';

Future<T?> showAppDialog<T>({
  required BuildContext context,
  required Widget child,
  bool barrierDismissible = true,
  String barrierLabel = '',
}) =>
    showGeneralDialog<T>(
    transitionBuilder: (context, animation, secondaryAnimation, widget) {
      final curvedAnimation = CurvedAnimation(
        parent: animation,
        curve: Curves.decelerate,
      );

      return ScaleTransition(
        scale: Tween<double>(begin: 0.8, end: 1).animate(curvedAnimation),
        child: FadeTransition(
          opacity: curvedAnimation,
          child: widget,
        ),
      );
    },
    transitionDuration: const Duration(milliseconds: 650),
    barrierDismissible: barrierDismissible,
    barrierLabel: barrierLabel,
    barrierColor: const Color(0x66000000),
    context: context,
    pageBuilder: (context, animation, secondaryAnimation) => AppDialog(
      child: child,
  ),
);
